home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / v cisle / sadanastroju / delicious_bookmarks-2.0.64-fx.xpi / chrome / deliciousBookmarks.jar / content / providerApis.js < prev    next >
Encoding:
Text File  |  2008-06-19  |  5.8 KB  |  188 lines

  1. var deliciousService = {
  2.   
  3.   _version : null,  
  4.   _serverName: "http://del.icio.us/",  
  5.   _secureServerName: "https://secure.del.icio.us/",
  6.   _betaServerName: "http://beta.delicious.com/",  
  7.   _betaSecureServerName: "https://secure.delicious.com/",
  8.   
  9.   initService : function() {
  10.   
  11.     this.cookieManager = Components.classes["@mozilla.org/cookiemanager;1"].
  12.                          getService(Components.interfaces.nsICookieManager);
  13.     var bundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].
  14.       getService(Components.interfaces.nsIStringBundleService);
  15.     var bundle = bundleService.createBundle(
  16.       "chrome://ybookmarks/locale/ybookmarks.properties");
  17.     this._version = bundle.GetStringFromName(
  18.       "extensions.ybookmarks.versionNum");
  19.   },
  20.  
  21.   getUserName: function() {
  22.       var del = Components.classes["@yahoo.com/socialstore/delicious;1"]
  23.                  .getService( Components.interfaces.nsISocialStore );      
  24.     return del.getUserName();
  25.   },
  26.  
  27.   getServiceName: function() {
  28.     return "Delicious";
  29.   },
  30.   
  31.   getVersionNumber : function() {
  32.     return this._version;
  33.   },
  34.     
  35.   _server: function() {
  36. //    return "http://preview.delicious.com/";
  37.     //return "http://qa.delicious.com/";
  38.     //return "http://staging.delicious.com/";
  39.     //return "http://del.icio.us/";
  40.     //return this._serverName;    
  41.     var del = Components.classes["@yahoo.com/socialstore/delicious;1"]
  42.                  .getService( Components.interfaces.nsISocialStore ); 
  43.     return del.home_url;
  44.   },
  45.   
  46.   _secureServer: function() {
  47. //    return "https://secure.delicious.com/";
  48. //    return "https://qa.delicious.com/";
  49.     //return "https://staging.delicious.com/";
  50.     //return "https://secure.del.icio.us/";    
  51.     var del = Components.classes["@yahoo.com/socialstore/delicious;1"]
  52.                  .getService( Components.interfaces.nsISocialStore ); 
  53.     if(del.home_url == this._betaServerName) {
  54.         return this._betaSecureServerName;
  55.     }                     
  56.     return this._secureServerName;
  57.   },
  58.   
  59.   _src: function() {
  60.     return "src=ffbmext" + this.getVersionNumber();
  61.   },
  62.   
  63.   _partner: function() {
  64.     return "&partner=ffbmext";
  65.   },
  66.  
  67.   _feedServer: function () {
  68. //      return "http://feeds.preview.delicious.com/";
  69.       //return "http://feeds.qa.delicious.com/";
  70.        return "http://feeds.staging.delicious.com/";
  71.   },
  72.   
  73.   getLoginUrl: function() {
  74.     return this._secureServer() + "login?" + this._src() + this._partner();
  75.   },
  76.  
  77.   getCreateUserUrl: function() {
  78.     return this._secureServer() + "register?" + this._src() + this._partner();
  79.   },
  80.   
  81.   getBundleUrl: function () {
  82.     return this._secureServer() + "settings/" + this.getUserName() + "/tags/bundle";
  83.   },
  84.   
  85.   getEditBundleUrl: function (aBundle) {
  86.     return this._secureServer() + "settings/" + this.getUserName() + "/tags/bundle" + "?bundle=" + encodeURIComponent(aBundle);
  87.   },
  88.  
  89.   getMoreAboutUrl : function(comp) {
  90.     return this._server() + "url?url=" + encodeURIComponent(comp);
  91.   },
  92.  
  93.   getSearchUrl : function(q) {
  94. //    return this._server() + "search?p=" + encodeURIComponent(q) + "&u=&chk=&context=all&fr=del_icio_us&lc=1";
  95.     return this._server() + "search?p=" + encodeURIComponent(q) + "&type=all";
  96.   },
  97.  
  98.   /** Generate a URL for the given path aPath, using delicious server */
  99.  
  100.   getUrl : function(aPath) {
  101.     if (aPath) {
  102.       return this._server() + aPath;
  103.     } else {
  104.       return this._server();
  105.     }
  106.   },
  107.  
  108.   /** Same as getUrl but also adds "src=" field */
  109.  
  110.   getUrl2 : function(aPath) {
  111.     return this.getUrl(aPath) + "?" + this._src();
  112.   },
  113.  
  114.   getTourUrl : function() {
  115.      return this.getUrl2("help/ff/success");
  116.   },
  117.  
  118.   getQuickTourUrl : function() {
  119.      //return this.getUrl("help/quicktour?tour=firefox");
  120.      return this.getUrl("help/firefox/bookmarks/quicktour"); 
  121.   },
  122.  
  123.   getPostRssUrl : function(url, title, notes, rss) {
  124.       var result = deliciousService.getUrl("post") + "?url=" +
  125.         encodeURIComponent(url) + "&title=" + encodeURIComponent(title);
  126.  
  127.       if (notes.length > 0) {
  128.          result += '&extended=' + encodeURIComponent(notes);
  129.       }
  130.  
  131.       result += "&tags=" + encodeURIComponent(rss) +
  132.         "&v=4&noui&jump=close&" + this._src();
  133.       return result;
  134.   },
  135.   getPostUrl : function(url, title, notes) {
  136.       var result = deliciousService.getUrl("post") + "?url=" +
  137.         encodeURIComponent(url) + "&title=" + encodeURIComponent(title);
  138.  
  139.       if (notes.length > 0) {
  140.          result += '&extended=' + encodeURIComponent(notes);
  141.       }
  142.  
  143.       result += "&v=4&noui&jump=close&" + this._src();
  144.       return result;
  145.   },
  146.   getNetworkFeedUrl : function () {
  147.       var user = this.getUserName();    
  148.     if(user) {
  149.         //For alpha release
  150.         //return (this._feedServer() + "v2/rss/network/" + user);
  151.         //return ("http://del.icio.us/rss/network/" + user);
  152.         return ("http://feeds.delicious.com/rss/network/" + user);
  153.     }
  154.     return "";    
  155.   },
  156.    getAlertFeedUrl : function () {
  157.     return this._feedServer() + "v2/rss/alerts";
  158.   },
  159.   getNetworkUrl : function () {      
  160.       var user = this.getUserName();    
  161.     if(user) {
  162.         return (this._server() + "network/" + user);
  163.     }
  164.     return (this._server() + "network/");
  165.   },
  166.   getLinks4uUrl : function () {
  167.       //return this._server()+"inbox/";
  168.       var user = this.getUserName();    
  169.     if(user) {
  170.           return this._server()+ "for/" + user;
  171.     } else {
  172.         return this._server() + "for/";
  173.     }
  174.   },
  175.   getTagometerUrl : function () {
  176.       return this._feedServer() + "v2/json/urlinfo/";
  177.   },
  178.   getAlertUrl : function () {
  179.       return this._server();
  180.   },
  181.   getRegisterSuccessUrl: function () {
  182.       return this._secureServer() + "register/tools";
  183.   }
  184. };
  185.  
  186. deliciousService.initService();
  187.  
  188.